package com.homedo.microservice.open.service.gateway.service;

import org.springframework.stereotype.Service;

import com.homedo.microservice.open.service.gateway.bean.po.RouteDomain;
import com.homedo.microservice.open.service.gateway.bean.po.enhanced.RouteDomainEnhanced;
import com.homedo.microservice.open.service.gateway.persistence.dao.RouteDomainDao;
import com.homedo.common.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import com.homedo.common.bean.vo.context.UserContext;
import com.homedo.common.dao.bean.po.base.BasePo;
import com.google.common.collect.Lists;
import com.homedo.common.util.Detect;
import java.util.List;

/**
 *
 * @author 作者 jgshun
 * @date   创建时间 2018年09月18日 11时30分20秒
 */
@Service
public class RouteDomainService extends BaseService<RouteDomain> {
	@Autowired
	private RouteDomainDao routeDomainDao;


        @Override
        public List<RouteDomainEnhanced> getEnhanceds(List<?> ids, UserContext userContext) {
            List<RouteDomain> routeDomains = routeDomainDao.getListByIds(ids, RouteDomain.class);

            if (!Detect.notEmpty(routeDomains)) {
            return null;
            }

            return this.convent2Enhanceds(routeDomains);
        }


        @Override
        public List<RouteDomainEnhanced> getEnhanceds4Active(List<?> ids, UserContext userContext) {
            List<RouteDomain> routeDomains = routeDomainDao.getListByIdsGreaterThanMark0(ids, RouteDomain.class);

                if (!Detect.notEmpty(routeDomains)) {
                return null;
                }

            return this.convent2Enhanceds(routeDomains);
         }


                @Override
                public List<RouteDomainEnhanced> convent2Enhanceds(List<? extends BasePo> pos) {
                    List<RouteDomain> routeDomains = (List<RouteDomain>) pos;
                        List<RouteDomainEnhanced> routeDomainEnhanceds = Lists.newArrayList();
                            routeDomains.forEach(e -> routeDomainEnhanceds.add(new RouteDomainEnhanced(e)));
                            return routeDomainEnhanceds;
                 }


}
